import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import com.jgoodies.forms.layout.*;
/*
 * Created by JFormDesigner on Mon Jun 04 21:24:12 PDT 2012
 */



/**
 * @author David Jaenisch
 */
public class MyJPanel extends JPanel {
	boolean buttonSwitch;
	
	public MyJPanel() {
		initComponents();
	}

	private void doActionPerformed(ActionEvent e) {
		youDidItLabel.setText("You did it, man!!!");
	}

	private void trollButtonActionPerformed(ActionEvent e) {
		background.setIcon(new ImageIcon(getClass().getResource("/PIsWn.jpg")));
	}

	private void clickBird(ActionEvent e) {
		if(buttonSwitch){
			background.setIcon(new ImageIcon(getClass().getResource("/0312-OSING-Trololo_full_600.jpg")));
		}
		else{
			background.setIcon(new ImageIcon(getClass().getResource("/fighting.png")));
		}
		buttonSwitch = !buttonSwitch;
	}

	private void initComponents() {
		// JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
		// Generated using JFormDesigner Evaluation license - David Jaenisch
		button1 = new JButton();
		youDidItLabel = new JLabel();
		trollButton = new JButton();
		doButton = new JButton();
		background = new JLabel();

		//======== this ========

		// JFormDesigner evaluation mark
		setBorder(new javax.swing.border.CompoundBorder(
			new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
				"JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
				javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
				java.awt.Color.red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});

		setLayout(null);

		//---- button1 ----
		button1.setIcon(new ImageIcon(getClass().getResource("/cardflyer.png")));
		button1.setOpaque(false);
		button1.setBackground(new Color(102, 255, 255));
		button1.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				clickBird(e);
			}
		});
		add(button1);
		button1.setBounds(new Rectangle(new Point(165, 255), button1.getPreferredSize()));

		//---- youDidItLabel ----
		youDidItLabel.setText("empty for the time being");
		youDidItLabel.setHorizontalAlignment(SwingConstants.CENTER);
		add(youDidItLabel);
		youDidItLabel.setBounds(390, 195, 175, 20);

		//---- trollButton ----
		trollButton.setText("Troll!");
		trollButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				trollButtonActionPerformed(e);
			}
		});
		add(trollButton);
		trollButton.setBounds(new Rectangle(new Point(460, 155), trollButton.getPreferredSize()));

		//---- doButton ----
		doButton.setIcon(new ImageIcon(getClass().getResource("/icewarrior.png")));
		doButton.setOpaque(false);
		doButton.setBackground(Color.red);
		doButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				doActionPerformed(e);
			}
		});
		add(doButton);
		doButton.setBounds(new Rectangle(new Point(380, 230), doButton.getPreferredSize()));

		//---- background ----
		background.setIcon(new ImageIcon(getClass().getResource("/0312-OSING-Trololo_full_600.jpg")));
		background.setVerticalAlignment(SwingConstants.TOP);
		background.setText("derrrp");
		add(background);
		background.setBounds(0, -5, 600, 400);

		{ // compute preferred size
			Dimension preferredSize = new Dimension();
			for(int i = 0; i < getComponentCount(); i++) {
				Rectangle bounds = getComponent(i).getBounds();
				preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
				preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
			}
			Insets insets = getInsets();
			preferredSize.width += insets.right;
			preferredSize.height += insets.bottom;
			setMinimumSize(preferredSize);
			setPreferredSize(preferredSize);
		}
		// JFormDesigner - End of component initialization  //GEN-END:initComponents
	}

	// JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
	// Generated using JFormDesigner Evaluation license - David Jaenisch
	private JButton button1;
	private JLabel youDidItLabel;
	private JButton trollButton;
	private JButton doButton;
	private JLabel background;
	// JFormDesigner - End of variables declaration  //GEN-END:variables
}
